using Dapper.Contrib.Extensions;
using Publicuse.Entity.AttributeUtil;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace Publicuse.Entity
{
    /// <summary>
    /// 系统后台作业信息
    /// </summary>
    [DBTable("`geeker-quzrttaskoptions`", "系统后台作业信息")]
    [Table("`geeker-quzrttaskoptions`")]
    [SugarTable("`geeker-quzrttaskoptions`")]
    public class QuzrtTaskOptions : BaseModel<long>
    {
        public string TaskName { get; set; }
        public string GroupName { get; set; }
        public string Intervale { get; set; }
        public string ParamData { get; set; } = "";
        public string HeaderData { get; set; } = "";
        public string RequestType { get; set; }

        public string ApiUrl { get; set; }
        public DateTime? LastRunTime { get; set; }
        public QuzrtTaskOptions()
        {
            this.Id = 0;
        }
    }

    /// <summary>
    /// 查询参数
    /// </summary>
    public class QuartzQuery : CommonQuery
    {
        public string TaskName { get; set; }

        public string GroupName { get; set; }

        public string RequestType { get; set; }

        public QuartzQuery()
        {
            this.exportName = GetExportName;
            this.pageIndex = 1;
            this.pageSize = 17;
        }

        public static string GetExportName
        {
            get { return "quartz"; }
        }
    }

    /// <summary>
    /// 运行日志
    /// </summary>
    [Table("`dd-quartztasklog`")]
    public class QuartzTaskLog
    {
        [Remark("作业编号")]
        public int qId { get; set; }

        [Remark("作业名称")]
        public string TaskName { get; set; }

        [Remark("执行开始时间")]
        public string BeginDate { get; set; }

        [Remark("执行完成时间")]
        public string EndDate { get; set; }

        [Remark("执行结果")]
        public string Msg { get; set; }
    }

    /// <summary>
    /// 操作类型
    /// </summary>
    public enum QuartzJobAction
    {
        /// <summary>
        /// 正常
        /// </summary>
        Normal = 0,

        /// <summary>
        /// 添加
        /// </summary>
        Add = 1,

        /// <summary>
        /// 删除
        /// </summary>
        Delete = 2,

        /// <summary>
        /// 修改
        /// </summary>
        Update = 3,

        /// <summary>
        /// 暂停
        /// </summary>
        Suspend = 4,

        /// <summary>
        /// 停止等待重启
        /// </summary>
        Stop = 5,

        /// <summary>
        /// 启动
        /// </summary>
        Start = 6,

        /// <summary>
        /// 立即执行
        /// </summary>
        Run = 7,

        /// <summary>
        /// 停止所有
        /// </summary>
        StopAll = 8,

        /// <summary>
        /// 重启所有
        /// </summary>
        StartAll = 9
    }
}
